<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>消息中心</title>
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>

    <link rel="stylesheet" href="../js/libs/sui/sm.min.css">
    <link rel="stylesheet" href="../iconfont/iconfont.css">
    <link rel="stylesheet" href="../less/main.css"/>

    <script type='text/javascript' src='../js/libs/jquery-3.1.0.min.js' charset='utf-8'></script>
    <script type="text/javascript">
        var Zepto = jQuery;
    </script>
    <script type='text/javascript' src='../js/libs/sui/sm.min.js' charset='utf-8'></script>
    <script src="../js/libs/juicer-min.js"></script>
    <script src="../js/libs/jquery.md5.js"></script>
    <script src="../js/api.js"></script>
    <script src="../js/utils.js"></script>
    <script src="../js/common.js"></script>
</head>
<body>
<!--消息中心-->
<div class="page bg-white">
    <!-- 头部-->
    <div class="head-no-toolbar bg-self-green no-left-icon">
        <span class="icon iconfont c-white p-l" onclick="javascript:api.closeWin();">&#xe61f;</span>
        <span class="c-white t-center">消息中心</span>
    </div>

    <div class="content pull-to-refresh-content t-0" data-ptr-distance="20">
        <div class="pull-to-refresh-layer">
            <div class="preloader"></div>
            <div class="pull-to-refresh-arrow"></div>
        </div>

        <div class="list-block set-ul-b m-0">
            <ul id="info-center-list">
                <!--
                <li class="item-content">
                    <div class="item-inner set-div-b">
                        <div class="item-title">福原爱:霞姐太强找不到机会</div>
                        <div class="item-after f-time">2016-08-05 10:25:26</div>
                    </div>
                </li>
                -->

            </ul>
        </div>
    </div>
</div>
<script id="notice-info-tpl" type="text/template">
    {@each noticeList as it,index}
    <li class="item-content" data-notice-title="&{it.TITLE}" data-notice-date="&{it.SEND_DATE}" data-notice-content="&{it.CONTENT}">
        <div class="item-inner set-div-b">
            <div class="item-title">&{it.TITLE}</div>
            <div class="item-after f-time">&{it.SEND_DATE}</div>
        </div>
    </li>
    {@/each}
</script>
<script>
    apiready=function(){
        juicer.set({
            'tag::operationOpen': '{@',
            'tag::operationClose': '}',
            'tag::interpolateOpen': '&{',
            'tag::interpolateClose': '}',
            'tag::noneencodeOpen': '$${',
            'tag::noneencodeClose': '}',
            'tag::commentOpen': '{#',
            'tag::commentClose': '}',
            'strip': false,
            'cache': false
        });
        //查询最新通知sql
        var sql="SELECT * from noticeinfo";
        var page=1;

        dbQuery(page,10,sql,true,function(ret,err){
            if(isObject(ret)&&ret.statusCode==0){

                if(ret.result.length!=0){
                    var noticeData={
                        noticeList:ret.result
                    };
                    $("#info-center-list").html(juicer($("#notice-info-tpl").html(),noticeData));
                }else{
                    toast("暂无通知");
                }
            }
        });

        // 下拉刷新最新通知
        $(document).on("refresh", ".pull-to-refresh-content", function () {
            page++;
            dbQuery(page, 10, sql, false, function (ret, err) {
                if (isObject(ret) && (ret.statusCode == 0)) {
                    var noticeData={
                        noticeList:ret.result
                    };
                    if (noticeData.noticeList.length > 0) {
                        $("#info-center-list").html(juicer($("#notice-info-tpl").html(),noticeData));
                    } else {
                        toast("已经加载完毕了");
                        page--;
                    }
                }
                $.pullToRefreshDone(".pull-to-refresh-content");
            });

        });

        //点击通知，进入详情页面
        $("#info-center-list").on("click",".item-content",function(){
            var $this = $(this);
            openWin("notice-detail", "notice-detail.html", {
                noticeTitle : $this.data("noticeTitle"),
                noticeDate : $this.data("noticeDate"),
                noticeContent: $this.data("noticeContent")
            });
        });
    };
</script>
<script>$.init();</script>
</body>
</html>






